<template>
	<view>
		<uni-list>
			 <uni-list-item v-for="(value, key) in salaryFields" :key="key" showExtraIcon="true" :title="value.label">
			    <template v-slot:footer>
			      <view class="mr-12 font-extralight">{{ userSalary?.[key] || '已读取或未发布' }}</view>
			    </template>
			  </uni-list-item>
		</uni-list>
	</view>
</template>

<script setup lang="ts">
	import { ref, onMounted } from 'vue';
	import { getUserProfile, getUserSalary } from "@/api/system/user/profile";
	import { parseTime } from "@/utils/ruoyi";
	import { useUserStore } from '@/store/modules/user';

	const store = useUserStore();

	const userSalary = ref<any>(null);
	const salaryFields = {
		basicSalary: { label: "基本工资" },
		performanceSalary: { label: "绩效工资" },
		areaAllowance: { label: "地区津贴" },
		highlandAllowance: { label: "高原补贴" },
		foodAllowance: { label: "副食补助" },
		seniorityAllowance: { label: "工龄补贴" },
		waterElectricityAllowance: { label: "水电补贴" },
		trafficFee: { label: "交通费" },
		heatingAllowance: { label: "取暖费" },
		mealAllowance: { label: "误餐费" },
		positionAllowance: { label: "岗位津贴" },
		educationFluctuation: { label: "职称浮动工资" },
		oldStaffSalary: { label: "老职工工资" },
		meatAllowance: { label: "肉食补助" },
		overtimePay: { label: "加班费" },
		laundryFee: { label: "洗理费" },
		childrenEducationFee: { label: "子女教育费" },
		totalSalary: { label: "应发工资总额" },
		medicalInsurance: { label: "医疗保险" },
		pensionDeduction: { label: "补扣养老金" },
		housingFundDeduction: { label: "补扣公积金" },
		unemploymentInsuranceDeduction: { label: "补扣失业金" },
		medicalInsuranceDeduction: { label: "补扣医疗保险" },
		annualPensionDeduction: { label: "补扣年金" },
		publicAccumulationFund: { label: "公积金" },
		mealFee: { label: "伙食费" },
		unionFee: { label: "会费" },
		deductionTotal: { label: "扣款小计" },
		netSalary: { label: "实发小计" },
	};
	const getSalary = async () => {
		try {
			userSalary.value = await getUserSalary({ id: store.user.id });
		} catch (error) {
			console.error("获取用户信息失败", error);
		}
	};

	onMounted(() => {
		getSalary();
	});
</script>

<style lang="scss">

</style>